package com.example.oa;

import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class ApplicationListener implements ServletContextListener, ServletContextAttributeListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println(" contextInitialized 应用程序启动");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println(" contextDestroyed 应用程序关闭");
    }

    @Override
    public void attributeAdded(ServletContextAttributeEvent event) {
        System.out.println("application attribute added"+event.getName()+ "-->"+ event.getValue());
    }

    @Override
    public void attributeRemoved(ServletContextAttributeEvent event) {
        System.out.println("application attribute Removed"+event.getName()+ "-->"+ event.getValue());
    }

    @Override
    public void attributeReplaced(ServletContextAttributeEvent event) {
        System.out.println("application attribute Replaced"+event.getName()+ "-->"+ event.getValue());
    }
}

